package com.demospringboot.system.controller;

import com.demospringboot.common.vo.Result;
import com.demospringboot.system.entity.dto.LoginDto;
import com.demospringboot.system.entity.dto.UserDto;
import com.demospringboot.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class AuthController {
    @Autowired
    private IUserService userService;

    @PostMapping("/login")
    public Result<UserDto> login(@RequestBody LoginDto loginDto) {
        try {
            UserDto userDto = userService.login(loginDto);
            return Result.success(userDto);
        } catch (RuntimeException e) {
            return Result.fail(e.getMessage());
        }
    }
} 